<script>
$(function(){
    $('img[class=addcart]').click(function(event){
        $('#cart_pid').val($(this).attr('rel'));
        // 取消事件冒泡
        event.stopPropagation();

        var offset = $(event.target).offset();
        $("#cart_confirm").css({ top: offset.top + $(event.target).height() + "px", left: offset.left-80 });
        $('#cart_confirm').show();
    });
    $('#close_cart').click(function(){
        $('#cart_confirm').hide();
    });
    $('#submit_cart').click(function(){
        $.post(location.href,{pid:$('#cart_pid').val(),num:$('#cart_pnum').val(),price:$('#price').val()},function(data){
            if (data.state <= 0)
            {
                alert(data.message);
                return false;
            }
            dialogMessage(data.message,'green');
        },'json');
    });

    $('#searchtype').val(INPUT_GET.searchtype);
    $('#keyword').val(INPUT_GET.keyword);
});
</script>
<div class="search">
    <form id='search'>
        <span>
            <select name="searchtype" id="searchtype" class="select1">
                <option>请选择查询类型</option>
                <option value="code">货号</option>
                <option value="product_name">商品名称（慢）</option>
                <option value="systemtype">系统类型</option>
            </select>
        </span>

        <span>
            <input type="text" name="keyword" id="keyword" value="" />
        </span>

        <span><input type="submit" value="搜索" /><?php echo showhide($_GET); ?></span>
    </form>
</div>
<div class="line_1"></div>
<table width="100%" cellpadding="0" cellspacing="0" border="0" class="table1">
       <tr>
            <th class="th0" rel="product_id">编号</th>
            <th class="th1">商品民称</th>
            <th class="th0" rel="code">货号</th>
            <th class="th1" rel="num">库存</th>
            <th class="th1" rel="sold_num">已售出</th>
            <th class="th1" rel="systemtype">系统类型</th>
            <th class="th1" rel="created_time">创建时间</th>
            <th class="th0">操作</a>
       </tr>
       <?php foreach($this->products as $product): ?> 
       <tr>
            <td><?php echo $product['product_id']; ?></td>
            <td><?php echo $product['name']; ?></td>
            <td><?php echo $product['code']; ?></td>
            <td><?php echo $product['num']; ?></td>
            <td><?php echo $product['sold_num']; ?></td>
            <td><?php echo $product['systemtype']; ?></td>
            <td><?php echo date('Y-m-d H:i:s',$product['created_time']); ?></td>
            <td><?php echo opt('cart','javascript:;',"title='添加到后台购物车' class='addcart' rel='{$product['product_id']}'"); ?></td>
       </tr>
       <?php endforeach; ?>
</table>
<div class="page_num">
     <div class="fl">
        <span style="color:red">第二步：请添加商品到<?php echo $this->currc['username']; ?>的购物车</span>
     </div>
     <div class="fr">
        <p class="cpager">
            <?php echo $this->pager; ?>
        </p>
     </div>
</div>
<div id='cart_confirm' style="display:none;width:auto;height:auto;background:skyblue;padding:5px;font-weight:bold;font-family:'黑体';font-size:14px;position:fixed;">
    数量：<input style="width:40px;height:14px;" id="cart_pnum" value="1" /><br/>单价：<input style="width:40px;height:14px;" id="price" value="0.00" /><br/><input type="submit" class="btn1" id="submit_cart" value="确定" /><input type="button" value="关闭" id='close_cart'/><input type="hidden" id="cart_pid" value=''/>
</div>